import requests


def fun(title, url):
    URL = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=ce4804e3-9d04-4fb9-be0d-56ae58067ffb'
    mHeader = {'Content-Type': 'application/json; charset=UTF-8'}
    mBody = {
        "msgtype": "text",
        "text": {
            "content": title + url
        }
    }
    # 注意：json=mBody  必须用json
    requests.post(url=URL, json=mBody, headers=mHeader)


headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36'
}
resp = requests.get(
    'https://r.inews.qq.com/gw/event/pc_hot_ranking_list?ids_hash=&offset=0&page_size=50&appver=15.5_qqnews_7.1.60',
    headers=headers)
data = resp.json()
list = data['idlist']

for news in list:

    for new in news['newslist'][1:]:
        fun(new['title'], new['surl'])
